import { BrowserModule } from '@angular/platform-browser';
import { ModuleWithProviders , NgModule } from '@angular/core';

import { LOADING_STATE , ScriptLoaderConfig , ScriptLoader } from './providers/scriptLoader';

import { MapComponent } from './components/tmap.component';
import { MarkerDirective } from './components/marker.directive';
import { ControlDirective } from './components/control.directive';

import { MapService } from './providers/mapService';



import { TMap } from './types/TMap';

@NgModule({
  declarations: [
      MapComponent, MarkerDirective, ControlDirective
  ],
  exports: [
    MapComponent, MarkerDirective, ControlDirective
  ]
})
export class TiandituModule {

    public static forRoot(_config?: ScriptLoaderConfig): ModuleWithProviders {
        return {
          ngModule: TiandituModule,
          providers: [
              { provide: ScriptLoaderConfig, useValue: _config },
              MapService,
              ScriptLoader
            ]
        };
      }
}

export { TMapInstance, MapOptions } from './types/Map';

declare global {
  interface Window {
    _scriptLoadState: LOADING_STATE;
    T: TMap;
    _loadingCallbacks: Array<() => void>;
    mapinit: () => void;
  }
}
